import datetime
import threading
import time
from bs4 import BeautifulSoup #网页解析，拿数据
import re #正则表达式，文字匹配
import urllib.request,urllib.error #指定url，获取网页数据
import xlwt #进行excel操作
import requests
import json
# def fun1():
#     fun2()
#     # 如果需要每天都执行
#     t = threading.Timer(86400, fun1)
#     t.start()
url1 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963137498624&date=2022-04-21"  #6:20
url2 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963137498624&date=2022-04-21"  #8:00
url3 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963137498625&date=2022-04-21"  #10:10 2
url4 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963154275850&date=2022-04-21"  #12:40  23
url5 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963171053070&date=2022-04-21"  #13:00  2
url6 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963187830284&date=2022-04-21"   #13:50  2
url7 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963271716364&date=2022-04-21"   #16:10 2
url8 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963271716365&date=2022-04-21"  #17:20 2
url9 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963288493573&date=2022-04-21"  #18:00 2
url10 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963305270789&date=2022-04-21"  #19:00 2
url11 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963322048003&date=2022-04-21"  #20:15 2
url12 = "http://hqapp1.bit.edu.cn/vehicle/get-reserved-seats?id=1740519963372379648&date=2022-04-21"  #21:10 2
workboob = xlwt.Workbook(encoding="utf-8")
worksheet = workboob.add_sheet('timesheet')
list1 = []
list2 = []
list3 = []
list4 = []
list5 = []
list6 = []
list7 = []
list8 = []
list9 = []
list10 = []
list11 = []
list12 = []
anslist = [[],list1,list2,list3,list4,list5,list6,list7,list8,list9,list10,list11,list12]
urllist = ["0",url1,url2,url3,url4,url5,url6,url7,url8,url9,url10,url11,url12]

threadinglist = []
def fun1():
    task(1)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '06:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun1)
        t.start()
        threadinglist.append(t)
def fun2():
    task(2)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '07:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun2)
        t.start()
        threadinglist.append(t)
def fun3():
    task(3)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '09:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun3)
        t.start()
        threadinglist.append(t)
def fun4():
    task(4)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '11:50:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun4)
        t.start()
        threadinglist.append(t)
def fun5():
    task(5)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '12:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun5)
        t.start()
        threadinglist.append(t)
def fun6():
    task(6)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '13:00:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun6)
        t.start()
        threadinglist.append(t)
def fun7():
    task(7)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '15:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun7)
        t.start()
        threadinglist.append(t)
def fun8():
    task(8)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '16:30:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun8)
        t.start()
        threadinglist.append(t)
def fun9():
    task(9)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '17:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun9)
        t.start()
        threadinglist.append(t)
def fun10():
    task(10)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '18:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun10)
        t.start()
        threadinglist.append(t)
def fun11():
    task(11)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '19:25:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun11)
        t.start()
        threadinglist.append(t)
def fun12():
    task(12)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '20:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, fun12)
        t.start()
        threadinglist.append(t)
def func1():
    task(1)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '6:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func1)
        t.start()
        threadinglist.append(t)
def func2():
    task(2)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '08:00:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func2)
        t.start()
        threadinglist.append(t)
def func3():
    task(3)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '10:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func3)
        t.start()
        threadinglist.append(t)
def func4():
    task(4)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '12:40:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func4)
        t.start()
        threadinglist.append(t)
def func5():
    task(5)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '13:00:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func5)
        t.start()
        threadinglist.append(t)
def func6():
    task(6)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '13:50:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func6)
        t.start()
        threadinglist.append(t)
def func7():
    task(7)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '16:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func7)
        t.start()
        threadinglist.append(t)
def func8():
    task(8)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '17:20:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func8)
        t.start()
        threadinglist.append(t)
def func9():
    task(9)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '18:00:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func9)
        t.start()
        threadinglist.append(t)
def func10():
    task(10)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '19:00:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func10)
        t.start()
        threadinglist.append(t)
def func11():
    task(11)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '20:15:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func11)
        t.start()
        threadinglist.append(t)
def func12():
    task(12)
    now_time = datetime.datetime.now()
    time1 = datetime.datetime.strptime(
        str(datetime.datetime.now().year) + '-' + str(datetime.datetime.now().month) + '-' + str(
            datetime.datetime.now().day) + ' ' + '21:10:00', '%Y-%m-%d %H:%M:%S')
    if now_time <= time1 - datetime.timedelta(seconds=60):
        t = threading.Timer(60, func12)
        t.start()
        threadinglist.append(t)


def task(i):
    print("======================recording=========================")
    response = requests.get(urllist[i])
    jsondata = response.json()
    data = jsondata["data"]
    # reservation_num = data["reservation_num"]
    # reservation_num #剩余位置数 有一个人在我写程序的时候买了票，是老师实锤了
    reserved_count = data["reserved_count"]
    #reserved_count  # 已预定的座位数
    anslist[i].append(reserved_count)



def main():
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime1 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '06:10:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime1:
    #     wait_time = (positiontime1 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun1)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[1])):
    #     print(anslist[1][i])
    #     worksheet.write(1,i,anslist[1][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime2 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '06:50:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime2:
    #     wait_time = (positiontime2 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun2)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[2])):
    #     print(anslist[2][i])
    #     worksheet.write(2,i,anslist[2][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime22 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '07:50:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime22:
    #     wait_time = (positiontime22 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, func2)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[2])):
    #     print(anslist[2][i])
    #     worksheet.write(42,i,anslist[2][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime3 = datetime.datetime.strptime(
    #     str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '09:00:00',
    #     '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime3:
    #     wait_time = (positiontime3 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun3)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[3])):
    #     print(anslist[3][i])
    #     worksheet.write(3, i, anslist[3][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime32 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '10:00:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime32:
    #     wait_time = (positiontime32 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, func3)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[3])):
    #     print(anslist[3][i])
    #     worksheet.write(43,i,anslist[3][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime4 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '11:30:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime4:
    #     wait_time = (positiontime4 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun4)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[4])):
    #     print(anslist[4][i])
    #     worksheet.write(4,i,anslist[4][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime42 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '12:30:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime42:
    #     wait_time = (positiontime42 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, func4)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[4])):
    #     print(anslist[4][i])
    #     worksheet.write(44,i,anslist[4][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime5 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '11:50:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime5:
    #     wait_time = (positiontime5 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun5)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[5])):
    #     print(anslist[5][i])
    #     worksheet.write(5,i,anslist[5][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime52 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '12:50:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime52:
    #     wait_time = (positiontime52 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, func5)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[5])):
    #     print(anslist[5][i])
    #     worksheet.write(45,i,anslist[5][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime6 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '12:40:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime6:
    #     wait_time = (positiontime6 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun6)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[6])):
    #     print(anslist[6][i])
    #     worksheet.write(6,i,anslist[6][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime62 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '13:40:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime62:
    #     wait_time = (positiontime62 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, func6)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[6])):
    #     print(anslist[6][i])
    #     worksheet.write(46,i,anslist[6][i])
    # print("========================once finished===========================")
    # threadinglist.clear()
    # now_time = datetime.datetime.now()
    # now_year = now_time.year
    # now_month = now_time.month
    # now_day = now_time.day
    #
    # positiontime7 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '15:00:00',
    #                                      '%Y-%m-%d %H:%M:%S')
    #
    # if now_time <= positiontime7:
    #     wait_time = (positiontime7 - now_time).total_seconds()
    # else:
    #     wait_time = 0
    #
    # t = threading.Timer(wait_time, fun7)
    # t.start()
    # threadinglist.append(t)
    # for k in threadinglist:
    #     k.join()
    #
    # for i in range(len(anslist[7])):
    #     print(anslist[7][i])
    #     worksheet.write(7,i,anslist[7][i])
    # print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime72 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '16:00:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime72:
        wait_time = (positiontime72 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func7)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[7])):
        print(anslist[7][i])
        worksheet.write(47,i,anslist[7][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime8 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '16:10:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime8:
        wait_time = (positiontime8 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, fun8)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[8])):
        print(anslist[8][i])
        worksheet.write(8,i,anslist[8][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime82 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '17:10:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime82:
        wait_time = (positiontime82 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func8)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[8])):
        print(anslist[8][i])
        worksheet.write(48,i,anslist[8][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime9 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '16:50:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime9:
        wait_time = (positiontime9 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, fun9)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[9])):
        print(anslist[9][i])
        worksheet.write(9,i,anslist[9][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime92 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '17:50:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime92:
        wait_time = (positiontime92 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func9)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[9])):
        print(anslist[9][i])
        worksheet.write(49,i,anslist[9][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime10 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '17:50:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime10:
        wait_time = (positiontime10 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, fun10)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[10])):
        print(anslist[10][i])
        worksheet.write(10,i,anslist[10][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime102 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '18:50:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime102:
        wait_time = (positiontime102 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func10)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[10])):
        print(anslist[10][i])
        worksheet.write(50,i,anslist[10][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime11 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '19:05:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime11:
        wait_time = (positiontime11 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, fun11)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[11])):
        print(anslist[11][i])
        worksheet.write(11,i,anslist[11][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime112 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '20:05:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime112:
        wait_time = (positiontime112 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func11)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[11])):
        print(anslist[11][i])
        worksheet.write(51,i,anslist[11][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime12 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '20:00:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime12:
        wait_time = (positiontime12 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, fun12)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[12])):
        print(anslist[12][i])
        worksheet.write(12,i,anslist[12][i])
    print("========================once finished===========================")
    threadinglist.clear()
    now_time = datetime.datetime.now()
    now_year = now_time.year
    now_month = now_time.month
    now_day = now_time.day

    positiontime122 = datetime.datetime.strptime(str(now_year) + '-' + str(now_month) + '-' + str(now_day) + ' ' + '21:00:00',
                                         '%Y-%m-%d %H:%M:%S')

    if now_time <= positiontime122:
        wait_time = (positiontime122 - now_time).total_seconds()
    else:
        wait_time = 0

    t = threading.Timer(wait_time, func12)
    t.start()
    threadinglist.append(t)
    for k in threadinglist:
        k.join()

    for i in range(len(anslist[12])):
        print(anslist[12][i])
        worksheet.write(52,i,anslist[12][i])
    print("========================once finished===========================")

    workboob.save('test02.xls')


if __name__ == '__main__':
    main()
